package com.unlcn.erp.hyc.interfaces.api.schedule;

import com.unlcn.erp.hyc.interfaces.backend.service.CallOrderByHYCService;
import org.joda.time.DateTime;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
 * Created by zhiche024 on 2017/9/19.
 */
public class CallOrderByHYCPort implements Job{
    private static final Logger LOGGER = LoggerFactory.getLogger(CallOrderByHYCPort.class);

    @Autowired
    private CallOrderByHYCService callOrderByHYCService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        LOGGER.info("CallOrderByHYCPort job startTime: {}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss.SSS"));
        try {
           callOrderByHYCService.getOrderCodes();
        }catch (Exception e){
            e.printStackTrace();
            LOGGER.error("CallOrderByHYCPort 定时任务保存出错 error: {}", e);
        }
        LOGGER.info("CallOrderByHYCPort job endTime: {}",DateTime.now().toString("yyyy-MM-dd HH:mm:ss.SSS"));
    }
}
